package com.talent.controller;

import com.talent.common.Result;
import com.talent.pojo.vo.FileUploadVO;
import com.talent.service.FileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件上传控制器
 */
@RestController
@RequestMapping("/api/upload")
@Slf4j
public class FileController {

    @Autowired
    private FileService fileService;

    /**
     * 上传文件
     */
    @PostMapping("/file")
    public Result<FileUploadVO> uploadFile(@RequestParam("file") MultipartFile file,
                                           @RequestParam(required = false) String type) {
        log.info("上传文件：{}, 类型：{}", file.getOriginalFilename(), type);
        FileUploadVO result = fileService.uploadFile(file, type);
        return Result.success(result);
    }
}
